<?php

require_once __DIR__."/../config/defines.php";

define("__INDEX__", true);

require_once __DIR__."/../config/config.php";

if(defined("WC_NOT_INSTALLED")) {
	header("Location: ../");
} else {
	echo "<pre>";
	if(isset($_REQUEST["service"]) && trim($_REQUEST["service"]) != "") {
		$wcServiceManager = WCServicesManager::I();
		$wcService = $wcServiceManager->currentService();
		$json = $wcService->getInterface();

		echo "/**\n";
		echo " * @class {$json->class} @todo document me\n";
		echo " *\n";
		echo " * Service: {$_REQUEST["service"]}\n";
		echo " * Interface:\n";
		echo " *\tSupported request methods:\n";
		foreach($json->methods as $method) {
			echo " *\t\t- {$method}\n";
		}
		echo " *\tRequired URL parameters:";
		if(count($json->params->url) > 0) {
			echo "\n";
			foreach($json->params->url as $param) {
				echo " *\t\t- {$param}\n";
			}
		} else {
			echo " None\n";
		}
		echo " *\tRequired POST parameters:";
		if(count($json->params->params) > 0) {
			echo "\n";
			foreach($json->params->params as $param) {
				echo " *\t\t- {$param}\n";
			}
		} else {
			echo " None\n";
		}
		echo " *\tHas conflict with read-only status: ".($json->readonlyconflict ? "Yes" : "No")."\n";
		echo " *\tUse cache: ".($json->cache ? "Yes" : "No")."\n";
		echo " */\n";
	} else {
		echo "service?";
	}
	echo "</pre>";
}
